package com.beordie.dao.impl;

import com.beordie.dao.IGradeDao;
import com.beordie.model.Grade;
import com.beordie.utils.DBUtils;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;



public class GradeDaoImpl extends DBUtils implements IGradeDao {
    @Override
    public List<Grade> getAll() throws SQLException {
        String sql = "select * from grade";
        resultSet = super.query(sql, null);
        List<Grade> list = new ArrayList<>();
        if (resultSet != null) {
            while (resultSet.next()) {
                Grade grade = new Grade();
                grade.setGradeId(resultSet.getInt("gradeid"));
                grade.setGradeName(resultSet.getString("gradename"));
                list.add(grade);
            }
        }
        return list;
    }

    @Override
    public int getGradeByName(String gradeName) {
        return 0;
    }
}
